<%@ include file="_header.jspf" %>
<%@ page import="com.spartancoder.accommodation.models.AuthToken" %>
<%@ page import="com.spartancoder.accommodation.models.AccommodationSession" %>
<%@ page import="com.spartancoder.accommodation.beans.AccommodationSessionBean" %>
<% AuthToken authToken = (AuthToken)request.getAttribute("authToken"); %>

<div class="span-13">
<%
    AccommodationSessionBean as = AccommodationSession.fetchActive();
    if (as !=null) {
%>
    Sesiunea: <b><%=as.getName()%></b> este activa de la data de <%=as.getStartDate() %>.
<%  } else {  %>
    In acest moment nu exista o sesiune de cazari activa.
<%  } %>
    <br /><br />
    <h2>Bine ai venit!</h2>

    <p>Scopul acestui site este sa usureze cazarea studentilor
    in camine. Daca esti student la una dintre facultatile
    partenere atunci este deja inregistrat in sistem si te poti
    autentifica folosind codul numeric personal si parola
    generata automat primita pe email.</p>
    
    <p>Dupa autentificare o sa poti sa iti setezi sau sa iti
    modifici optiunile de cazare. Acest lucru este posibil pana
    cand sesiunea de cazare o sa fie inchisa de catre un
    administrator.
    </p>
</div>

<div class="span-7 last">
    <% if (authToken.isGuest()) { %>

    <form action="login.jsp">
        <fieldset>
            
            <label class="large text">Cnp:</label><br />
            <input type="text" name="user" /><br />

            <label class="large text">Parola:</label><br />
            <input type="password" name="password" />

            <button type="submit" class="button positive">
                <img src="images/icons/tick.png" />
                Autentificare
            </button>
        </fieldset>
    </form>

    <% } else if (authToken.isStudent()) { %>

        Salut <%=authToken.getStudent().getLastName()%>
    
    <% } else if (authToken.isAdmin()) { %>
        
        Salut <b><%=authToken.getAdministrator().getUser()%></b>
        <ul>
            <li><a href="admin/index.jsp">Zona administrativa</a></li>
            <li><a href="logout.jsp">Logout</a></li>
        </ul>

    <% } %>
</div>

<%@ include file="_footer.jspf" %>